package com.ouc.ouc.resolver;
import com.google.common.base.Preconditions;
import io.terminus.pampas.engine.handlebars.HandlebarsEngine;
//import com.ouc.pampas.HandlebarsEngine;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.view.AbstractTemplateView;

public class HandlebarsView extends AbstractTemplateView
{
  private HandlebarsEngine handlebarsEngine;
  private String path;
  
  protected void renderMergedTemplateModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    model.put("_PATH_", this.path);
    response.getWriter().write(this.handlebarsEngine.execPath(this.path, model, false));
  }
  
  void init(HandlebarsEngine handlebarsEngine, String path)
  {
    Preconditions.checkNotNull(handlebarsEngine, "A handlebarsEngine is required.");
    Preconditions.checkNotNull(path, "A path is required.");
    this.handlebarsEngine = handlebarsEngine;
    this.path = path;
  }
}
